package netWork;

import java.io.IOException;
import java.net.SocketException;
import java.util.HashSet;
import java.util.concurrent.ConcurrentHashMap;

/**
 * Created with IntelliJ IDEA.
 * Description: 中译英服务器
 * User: 王圆豪
 * Date: 2025-05-16
 * Time: 12:14
 */
public class UdpDictServer extends UdpEchoServer{
    private ConcurrentHashMap<String, String> map = new ConcurrentHashMap<>();

    public UdpDictServer(int port) throws SocketException {
        super(port);
        map.put("小猫", "cat");
        map.put("小狗", "dog");
        map.put("小鸭子", "duck");
        map.put("小猪", "pig");
        map.put("小羊", "sheep");
    }

    @Override
    public String process(String request){
        return map.getOrDefault(request,"未找到词条");
    }

    public static void main(String[] args) throws IOException {
        UdpDictServer server = new UdpDictServer(9090);
        server.start();
    }
}
